package com.study.controller.HRcontroller;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.study.model.pojo.HRpojo.AppTab;
import com.study.model.pojo.HRpojo.ResumeTab;
import com.study.service.HRservice.ResumeService;

//CrossOrigin 解决跨域
@CrossOrigin
@RequestMapping("resCon")
@RestController
public class ResumeController {

	@Autowired
	ResumeService reService;
	
	/**
	 * 查询面试状态为可录用的人员信息
	 * @return
	 */
	@RequestMapping("findByRe")
	public List<ResumeTab> findByResstate(){
		int a = 2;
		return reService.findByResstate(a);
	}
	
	/**
	 * 查询所有的简历信息
	 * @return
	 */
	@RequestMapping("resFindAll")
	public List<ResumeTab> findAll(){
		return reService.findAll();
	}
	
	/**
	 * 查询面试状态为预约的人员信息
	 * @return
	 */
	@RequestMapping("findByReYuYue")
	public List<ResumeTab> findByResstate2(){
		int a = 1;
		return reService.findByResstate(a);
	}
	
	/**
	 * 根据面试状态（2录用、4已入职），显示所有信息
	 * @return
	 */
	@RequestMapping("resfindByBetween")
	public List<ResumeTab> findByResstateOrResstate(){
		int a = 2, b = 4;
		return reService.findByResstateOrResstate(a, b);
	}
	
	/**
	 * 新增简历信息
	 * @param restab
	 * @return
	 */
	@RequestMapping("addRes")
	public List<ResumeTab> addResume(@RequestBody Map<String, String> map) {
		ResumeTab restab = new ResumeTab();
		//招聘申请编号（从招聘中获取 1、判断是否已招满   2、判断当前日期是否大于用工日期）
		AppTab apptab = new AppTab();
		apptab.setAppid(11);

		restab.setAppTab(apptab);
		restab.setResstate(1);
		restab.setResname(map.get("resname"));
		restab.setReseducation(Integer.parseInt(map.get("reseducation")));
		restab.setRescardid(map.get("rescardid"));
		restab.setRestel(map.get("restel"));
		restab.setRessex(Integer.parseInt(map.get("ressex")));
		restab.setResemail(map.get("resemail"));
		restab.setResedusch(map.get("resedusch"));
		restab.setResadd(map.get("resadd"));
		restab.setResremark(map.get("resremark"));
		System.out.println(restab);
		ResumeTab addResume = reService.addResume(restab);
		return reService.findAll();
	}
	
	/**
	 * 前端点击通过按钮，修改面试状态为可录用
	 * @param map
	 * @return
	 */
	@RequestMapping("editResState2")
	public List<ResumeTab> editAppState2(@RequestBody Map<String, String> map) {
		System.out.println(map.get("resid"));
		ResumeTab editAppState2 = reService.editResState2(map);
		return reService.findAll();
	}
	
	/**
	 * 前端点击通过按钮，修改面试状态为不录用
	 * @param map
	 * @return
	 */
	@RequestMapping("editResState3")
	public List<ResumeTab> editAppState3(@RequestBody Map<String, String> map) {
		System.out.println(map.get("resid"));
		ResumeTab editAppState3 = reService.editResState3(map);
		return reService.findAll();
	}
}
